]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dbusServices/extensions: Simplify actions handling
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 29 Jul 2021 22:58:18 +0000 (00:58 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 8 Feb 2022 19:11:19 +0000 (19:11 +0000)
GTK4 has dedicated API for widget-specific actions, make use of that
instead of explicitly managing an action group.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2012>

js/dbusServices/extensions/extensionPrefsDialog.js

index 8fa6a533b2686d3a11a5cf0d12a6a0c859925034..cdcb85215162f60abb8da1d6ff6282fa68d33343 100644 (file)
@@ -44,19 +44,32 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
         'errorView',
     ],
 }, class ExtensionPrefsErrorPage extends Gtk.Widget {
+    static _classInit(klass) {
+        super._classInit(klass);
+
+        klass.install_action('page.copy-error',
+            null,
+            self => {
+                const clipboard = self.get_display().get_clipboard();
+                clipboard.set(self._errorMarkdown);
+            });
+        klass.install_action('page.show-url',
+            null,
+            self => Gtk.show_uri(self.get_root(), self._url, Gdk.CURRENT_TIME));
+
+        return klass;
+    }
+
     _init(extension, error) {
         super._init({
             layout_manager: new Gtk.BinLayout(),
         });
+        this._addCustomStylesheet();
 
         this._uuid = extension.uuid;
         this._url = extension.metadata.url || '';
 
-        this._actionGroup = new Gio.SimpleActionGroup();
-        this.insert_action_group('page', this._actionGroup);
-
-        this._initActions();
-        this._addCustomStylesheet();
+        this.action_set_enabled('page.show-url', this._url !== '');
 
         this._gesture = new Gtk.GestureClick({
             button: 0,
@@ -106,27 +119,6 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
             this._expander.remove_css_class('expanded');
     }
 
-    _initActions() {
-        let action;
-
-        action = new Gio.SimpleAction({ name: 'copy-error' });
-        action.connect('activate', () => {
-            const clipboard = this.get_display().get_clipboard();
-            clipboard.set(this._errorMarkdown);
-        });
-        this._actionGroup.add_action(action);
-
-        action = new Gio.SimpleAction({
-            name: 'show-url',
-            enabled: this._url !== '',
-        });
-        action.connect('activate', () => {
-            Gio.AppInfo.launch_default_for_uri(this._url,
-                this.get_display().get_app_launch_context());
-        });
-        this._actionGroup.add_action(action);
-    }
-
     _addCustomStylesheet() {
         let provider = new Gtk.CssProvider();
         let uri = 'resource:///org/gnome/Shell/Extensions/css/application.css';